@extends('layouts.app') @section('content')
<link rel="stylesheet" href="/lv5/public/css/personIndex.css">
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-1">
            <?php $user = Auth::user() ?>
            <div class="avatar-header">
                <img class="avatar" src="/lv5/public/img/user/{{ $user->avatar }}" alt="">
                <div class="avatar-message">
                    <div>
                        <span class="index-username">{{ $user->name }}</span>&nbsp;
                        <p style="display:inline-block;">
                            <span class="identity">{{ $user->groupm }}</span>
                        </p>
                    </div>
                    <p class="avatar-detail">
                        <span>文章
                            <span>{{ $article_count }}</span>
                        </span>&nbsp;&nbsp;&nbsp;
                        <span>文章阅读总数
                            <span>{{ $read_count }}</span>
                        </span>&nbsp;&nbsp;&nbsp;
                        <span>收获的喜欢
                            <span>{{ $upvote_count }}</span>
                        </span>&nbsp;&nbsp;&nbsp;
                        <span>关注的专题
                            <span>0</span>
                        </span>
                    </p>
                </div>
            </div>
            <div class="index-bar">
                <ul>
                    <li>
                        <i class="fa fa-file-text-o" aria-hidden="true"></i>
                        <a href="{{ url('/article') }}"> 我的文章</a>
                    </li>
                    <li>
                        <i class="fa fa-check-circle-o" aria-hidden="true"></i>
                        <a id="person-paper" href="#">我写的日报</a>
                    </li>
                    <li>
                        <i class="fa fa-star-o" aria-hidden="true"></i> 收藏的文章</li>
                </ul>
            </div>
            @if (count($errors) > 0)
            <div class="alert alert-danger">
                {!! implode('
                <br>', $errors->all()) !!}
            </div>
            @endif
            <hr>
            <div id="person-articles">
                @foreach ($articles as $article)
                <div class="article row">
                    <h4>
                        <a class="article-title" href="{{ url('article/'.$article->id) }}">{{ $article->title }}</a>
                    </h4>
                    <p>于 {{ $article->created_at }} 创建</p>
                    <div class="content row">
                        <div class="col-md-7">
                            {{ mb_substr($article->body, 0, 70).'...' }}
                            <div>
                                <a href=" {{ url('category').'?name='.$article->category }} ">
                                    <span class="category">{{ $article->category }}</span>
                                </a>
                                &nbsp;&nbsp;&nbsp;阅读&nbsp;
                                <span>({{$article->read_total}})</span> &nbsp;&nbsp;&nbsp;回复&nbsp;
                                <span>{{ $article->reply_total }}</span> &nbsp;&nbsp;&nbsp;点赞&nbsp;
                                <span>{{ $article->upvote_total }}</span>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <img class="article-cover-user" src="/lv5/public/img/cover/{{$article->cover_img}}" alt="">
                        </div>
                        
                        <div class="col-md-3 operation">
                            <a href="{{ url('article/'.$article->id.'/edit') }}" class="btn btn-success btn-sm">编辑</a><br>
                            <button id="delete" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#myModal">删除</button>

                        </div>
                        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                        <h4 class="modal-title" id="myModalLabel">确认删除</h4>
                                    </div>
                                    <div class="modal-body">
                                        你确认删除这篇文章?
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                        <form action="{{ url('article/'.$article->id) }}" method="POST" style="display: inline;">
                                            {{ method_field('DELETE') }} {{ csrf_field() }}
                                            <button type="submit" class="btn btn-primary">确认</button>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <hr>
                </div>
                @endforeach
            </div>
        </div>
        <div class="col-md-2">
            <div>
                个人介绍
            </div>
            <div>此人很懒，什么都没有留下…

            </div>
        </div>
    </div>
</div>
@endsection